<?php
include_once 'Zend/Db/Table.php';
include_once 'Account.php';
Zend_Db_Table::setDefaultAdapter($db);

class Click extends Zend_Db_Table 
{
	protected $_name = 'affiliSt_clicks';
	
	/**
	 * add new click
	 *
	 * @param array
	 * @return boolean
	 */
	public function add($newClick)
	{
		try 
		{
			if ($this->insert($newClick))
			{
				return true;
			}
		}catch (Exception $e)
		{
			return false;
		}
	}
	
	public function getTotal($username)
	{
		$account = new Account();
		$accId = $account->getId($username);
		$total = $this->_db->fetchOne("SELECT COUNT(*) FROM $this->_name WHERE accId = $accId");
		return $total;
	}
}
?>